﻿@model SRF.Admin.Models.User
@{
    Layout = "~/Views/Shared/_EditDialog.cshtml";  
}
@using SRF.UI.Html
@section header{ 
    <script type="text/javascript" language="javascript">
        function changepsw_Success() {
            $("#changepswResult").text("密码修改成功").attr("class", "text-success");
        }
        function changepsw_Failure(ex) {
            $("#changepswResult").text(ex.responseText).attr("class", "text-error");
        }    
        function savepersonal_Success() {
            $("#personalResult").text("信息保存成功").attr("class", "text-success");
        }
        function savepersonal_Failure(ex) {
            $("#personalResult").text(ex.responseText).attr("class", "text-error");
        } 
        function changeTab(index) {
            $(".nav-tabs li.active").removeClass("active");
            $(".nav-tabs li").eq(index - 1).addClass("active").find("a").blur();
            $(".tabpage").hide();
            switch (index) {
                case 1:
                    $("#personalPage").show();
                    break;
                case 2:
                    $("#changepswPage").show();
                    break;
            }
        }
        function submitPersonal() {
            $.ajaxSubmit("personalform");
        }
        function submitNewPassword() {
            $.ajaxSubmit("changepswform");
        }
        $(function () {
            var $input = $("[name='NewPassword']"); 
        })
    </script>
}
<ul class="nav nav-tabs">
    <li class="active"><a href="javascript:changeTab(1);">个人信息</a> </li>
    <li><a href="javascript:changeTab(2);">修改密码</a> </li>
</ul>
@using (Ajax.BeginForm("SavePersonal", null, new AjaxOptions() { HttpMethod = "Post", OnSuccess = "savepersonal_Success", OnFailure = "savepersonal_Failure" }, new { @class = "form-horizontal", style = "", id = "personalform" }))
{  
    <div id="personalPage" class="tabpage">
        @Html.HiddenFor(m => m.Id)
        <table>
            <tr>
                <td>
                    <label class="control-label" for="Name">
                        姓名:</label>
                    @Html.TextBoxFor(m => m.Name)
                </td>
                <td>
                    <label class="control-label" for="Sex">
                        性别:</label>
                    @Html.EnumDropDownListFor(m => m.Sex)
                </td>
            </tr>
            <tr>
                <td>
                    <label class="control-label" for="Email">
                        邮件:</label>
                    @Html.TextBoxFor(m => m.Email)
                </td>
                <td>
                    <label class="control-label" for="Phone">
                        电话:</label>
                    @Html.TextBoxFor(m => m.Phone)
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <label class="control-label" for="IM">
                        IM:</label>
                    @Html.TextBoxFor(m => m.IM)
                </td>
            </tr>
            <tr>
                <td colspan="2" style="height:50px">
                    <span id="personalResult" style="padding-left: 80px"></span>
                    <input type="button" value="保存" class="btn btn-primary" style="float: right" onclick="submitPersonal();" />
                </td>
            </tr>
        </table>
    </div>
}
@using (Ajax.BeginForm("ChangePassword", null, new AjaxOptions() { HttpMethod = "Post", OnSuccess = "changepsw_Success", OnFailure = "changepsw_Failure" }, new { @class = "form-horizontal", style = "", id = "changepswform" }))
{  
    <div id="changepswPage" style="border: 0px solid red; display: none" class="tabpage">
        <table>
            <tr>
                <td>
                    <label class="control-label" for="Name">
                        登录名:</label>
                    <span class="display-label">@Html.Text("{0}", SRF.Security.SecurityContext.User.LoginId)</span>
                </td>
            </tr>
            <tr>
                <td>
                    <label class="control-label" for="Password">
                        旧密码:</label>
                    @Html.Password("OldPassword")
                </td>
            </tr>
            <tr>
                <td>
                    <label class="control-label" for="Password">
                        新密码:</label>
                    @Html.Password("NewPassword")
                </td>
            </tr>
            <tr>
                <td>
                    <label class="control-label" for="Password">
                        确认新密码:</label>
                    @Html.Password("ConfirmPassword")
                </td>
            </tr>
            <tr>
                <td>
                    <span id="changepswResult" style="padding-left: 20px"></span>
                    <input type="button" value="确定" class="btn btn-primary" style="float: right" onclick="submitNewPassword();" />
                </td>
            </tr>
        </table>
    </div> 
    @Html.Validation(typeof(SRF.Web.Areas.Admin.Models.ChangePasswordModel), "#changepswPage")  
}